﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace LynxWebLog
{
    public class CC_License
    {

        public static string GetLicense(string code)
        {
            string license = string.Empty;

            switch (code) {
                case "CC-BY":
                    license = @"<div class=""cc""><a rel=""license"" href=""http://creativecommons.org/licenses/by/3.0/deed.en_US"">
  <img alt=""Creative Commons License"" style=""border-width:0"" src=""http://i.creativecommons.org/l/by/3.0/88x31.png"" /></a><br />
  This work is licensed under a <a rel=""license"" href=""http://creativecommons.org/licenses/by/3.0/deed.en_US"">
  Creative Commons Attribution 3.0 Unported License</a>.</div>";
                    break;
                case "CC-BY-ND":
                    license = @"<div class=""cc""><a rel=""license"" href=""http://creativecommons.org/licenses/by-nd/3.0/deed.en_US"">
  <img alt=""Creative Commons License"" style=""border-width:0"" src=""http://i.creativecommons.org/l/by-nd/3.0/88x31.png"" /></a><br />
  This work is licensed under a <a rel=""license"" href=""http://creativecommons.org/licenses/by-nd/3.0/deed.en_US"">
  Creative Commons Attribution-NoDerivs 3.0 Unported License</a>.</div>";
                    break;
                case "CC-BY-SA":
                    license = @"<div class=""cc""><a rel=""license"" href=""http://creativecommons.org/licenses/by-sa/3.0/deed.en_US"">
  <img alt=""Creative Commons License"" style=""border-width:0"" src=""http://i.creativecommons.org/l/by-sa/3.0/88x31.png"" /></a><br />
  This work is licensed under a <a rel=""license"" href=""http://creativecommons.org/licenses/by-sa/3.0/deed.en_US"">
  Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</div>";
                    break;
                case "CC-BY-NC":
                    license = @"<div class=""cc""><a rel=""license"" href=""http://creativecommons.org/licenses/by-nc/3.0/deed.en_US"">
  <img alt=""Creative Commons License"" style=""border-width:0"" src=""http://i.creativecommons.org/l/by-nc/3.0/88x31.png"" /></a><br />
  This work is licensed under a <a rel=""license"" href=""http://creativecommons.org/licenses/by-nc/3.0/deed.en_US"">
  Creative Commons Attribution-NonCommercial 3.0 Unported License</a>.</div>";
                    break;
                case "CC-BY-NC-ND":
                    license = @"<div class=""cc""><a rel=""license"" href=""http://creativecommons.org/licenses/by-nc-nd/3.0/deed.en_US"">
  <img alt=""Creative Commons License"" style=""border-width:0"" src=""http://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png"" /></a><br />
  This work is licensed under a <a rel=""license"" href=""http://creativecommons.org/licenses/by-nc-nd/3.0/deed.en_US"">
  Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License</a>.</div>";
                    break;
                case "CC-BY-NC-SA":
                    license = @"<div class=""cc""><a rel=""license"" href=""http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US"">
  <img alt=""Creative Commons License"" style=""border-width:0"" src=""http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png"" /></a><br />
  This work is licensed under a <a rel=""license"" href=""http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US"">
  Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.</div>";
                    break;
                default:
                    break;
            }
            return license;
        }

        public static List<SelectListItem> BuildLicenseFlds(string filter, HttpContextBase context)
        {
            List<SelectListItem> licList = new List<SelectListItem>();
            foreach (string lic in (List<string>)context.Application["__ValidLicenseList"]) {
                licList.Add(new SelectListItem() { Value = lic, Text = lic, Selected = (filter == lic ? true : false) });
            }
            return licList;
        }

    }
}